// pages/transaction/transaction.ts
Page({
  data: {
    statusBarHeight: 0,
    income: '12,856',
    incomeGrowth: '12.5',
    expense: '3,240',
    expenseGrowth: '5.2',
    categories: [
      { type: 'income', icon: 'order-icon.png', name: '订单收入', amount: '¥10,560' },
      { type: 'income', icon: 'gift-icon.png', name: '活动补贴', amount: '¥1,250' },
      { type: 'expense', icon: 'service-icon.png', name: '平台服务费', amount: '-¥2,180' }
    ],
    tabs: ['全部', '收入', '支出', '订单收入', '平台服务费'],
    activeTab: 0,
    transactions: [
      { id: '1', title: '订单收入', time: '2023-11-15 14:30', amount: '+¥128.50', type: 'income' },
      { id: '2', title: '提现', time: '2023-11-14 09:15', amount: '-¥2,000.00', type: 'expense' },
      { id: '3', title: '订单收入', time: '2023-11-13 20:45', amount: '+¥86.30', type: 'income' }
    ]
  },

  onLoad() {
    const systemInfo = wx.getSystemInfoSync();
    this.setData({
      statusBarHeight: systemInfo.statusBarHeight || 0
    });
  },

  goBack() {
    wx.navigateBack();
  },

  showMonthPicker() {
    wx.showActionSheet({
      itemList: ['本月', '上月', '最近3个月'],
      success: (res) => {
        wx.showToast({
          title: '已选择: ' + ['本月', '上月', '最近3个月'][res.tapIndex],
          icon: 'none'
        });
      }
    });
  },

  switchTab(e: any) {
    const index = e.currentTarget.dataset.index;
    this.setData({
      activeTab: index
    });
  }
});
